home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / s342q12.lha / slist.h < prev    next >
C/C++ Source or Header  |  1994-12-28  |  4KB  |  90 lines

  1. /************************************************************************/
  2. /*                             sList.h                                  */
  3. /*      #include file for List.C.                                       */
  4. /************************************************************************/
  5. /************************************************************************/
  6. /*              List handling structures - generic sorted lists         */
  7. /************************************************************************/
  8. #ifndef slist_h
  9. #define slist_h
  10. typedef struct Slist      SListData;
  11. typedef struct sbasestuff SListBase;
  12. #define GetFirst(x)     (((x)->start != NULL) ? (x)->start->data :(void *)NULL)
  13. #define MoveAndClear(s, d)      (d)->start = (s)->start, (s)->start = NULL
  14. /*
  15. * This is the generic list structure normal link.  It contains a pointer
  16. * to the next element in the list and a pointer to a chunk of data.
  17. */
  18. struct Slist
  19.   {
  20.   void     *data;
  21.   SListData *next;
  22.  
  23.   };
  24. /*
  25. * This structure contains data and functions necessary to handle some given
  26. * instantiation of a list.  Included is a pointer to the data of the list,
  27. * and pointers to functions which should always be used for given functions
  28. * applied to the list.
  29. */
  30. struct sbasestuff
  31.   {
  32.   SListData *start;
  33.   void     *(*CheckIt)(void *d1, void *d2);
  34.   /*        int      (*cmp)(void *d1, void *d2); */
  35.   int      (*cmp)(void *d1, void *d2);
  36.   /*        char    *(*CheckIt)(void *d1, *d2); */
  37.   void     (*FreeFunc)(void *d);
  38.   /*      void     (*FreeFunc)(void *data);  */
  39.   /*        void     *(*EatLine)(char *line);     */
  40.   void     *(*EatLine)(char *line);
  41.  
  42.   };
  43. #define InitListValues(l, ci, xcmp, f, e)       (l)->start = NULL, (l)->CheckIt = ci,   (l)->cmp = xcmp, (l)->FreeFunc = f, (l)->EatLine = e
  44. /*
  45. * These definitions are for the listshow functions: behavior specification.
  46. */
  47. #define NO_REFRESH      0x01    /* for use with the mode argument       */
  48. #define ADVANCE         0x02    /* advance one in list                  */
  49. #define DEL_ACTIVE      0x04    /* if DEL is active                     */
  50. #define NO_HEADER       0x08    /* No header on list if set             */
  51. #define NO_ACTION       0x10    /* do nothing - just display            */
  52. #define PAGE_LABELS     0x20    /* show page labels                     */
  53. #define NO_BAR          0x40    /* show page labels                     */
  54. /*
  55. * These definitions are mode definitions of ListShow.
  56. */
  57. #define LS_NORMAL       0
  58. #define LS_ONTOP        1
  59. /*
  60. * This structure is used by listshow.c for displaying lists of data in
  61. * dynamic columns.
  62. */
  63. typedef struct
  64.   {
  65.   SListBase Data;
  66.   char *title;
  67.   int *critical;                  /* chars which cause exit       */
  68.   char (*DelFunc)();              /* If DEL key is touched        */
  69.   int left, right, top, bottom;   /* window to display in         */
  70.   int fg, bg, dfg, dbg;           /* colors                       */
  71.   int ColWidth;                   /* how wide are columns?        */
  72.   void (*DispFunc)();             /* displays data for you        */
  73.   char (*SelectorId)();         /* see if the selector agrees   */
  74.   int  (*UserInput)();
  75.  
  76.   }
  77. DisplayList;
  78. void *DispList(DisplayList *, void *, int  *, int);
  79. char MakeList(SListBase *, char *, FILE *);
  80. void AddData(SListBase *, void *, void (*)(void *),char );
  81. void KillData(SListBase *, void *);
  82. void KillList(SListBase *);
  83. void *GetLast(SListBase *);
  84. void *SearchList(SListBase *, void *);
  85. int  RunList(SListBase *, void (*)(void *));
  86. void FrontToEnd(SListBase *);
  87. void NoFree(void *);
  88. char *GetAString(char *, int , FILE *);
  89. #endif
  90.